﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Runtime.Serialization;
using Microsoft.SharePoint;

namespace SPREST.Models
{
    public static class ListExtension 
    {
        public static List<List> Convert(this SPListCollection listCollection)
        {
            List<List> lists = new List<List>();

            foreach (SPList list in listCollection)
            {
                lists.Add(list.Convert());
            }
            return lists;

        }

        public static List Convert(this SPList list)
        {
            return new List { ID = list.ID.ToString(), Title = list.Title, ListItems = list.Items };
        }
    }
}
